home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_perl.idb / usr / freeware / catman / p_man / cat3 / IPC::Open3.Z / IPC::Open3
Encoding:
Text File  |  1998-10-28  |  3.2 KB  |  133 lines

  1.  
  2.  
  3.  
  4.      IIIIPPPPCCCC::::::::OOOOppppeeeennnn3333((((3333))))   22223333////JJJJuuuullll////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))     IIIIPPPPCCCC::::::::OOOOppppeeeennnn3333((((3333))))
  5.  
  6.  
  7.  
  8.      NNNNAAAAMMMMEEEE
  9.       IPC::Open3, open3 - open a process for reading, writing, and
  10.       error    handling
  11.  
  12.      SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  13.           $pid = open3(\*WTRFH, \*RDRFH, \*ERRFH,
  14.                   'some cmd    and args', 'optarg', ...);
  15.  
  16.  
  17.      DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  18.       Extremely similar to _o_p_e_n_2(),    _o_p_e_n_3()    spawns the given $cmd
  19.       and connects RDRFH for reading, WTRFH    for writing, and ERRFH
  20.       for errors.  If ERRFH    is '', or the same as RDRFH, then
  21.       STDOUT and STDERR of the child are on    the same file handle.
  22.       The WTRFH will have autoflush    turned on.
  23.  
  24.       If WTRFH begins with "<&", then WTRFH    will be    closed in the
  25.       parent, and the child    will read from it directly.  If    RDRFH
  26.       or ERRFH begins with ">&", then the child will send output
  27.       directly to that file    handle.     In both cases,    there will be
  28.       a _d_u_p(2) instead of a    _p_i_p_e(2)    made.
  29.  
  30.       If you try to    read from the child's stdout writer and    their
  31.       stderr writer, you'll    have problems with blocking, which
  32.       means    you'll want to use _s_e_l_e_c_t(), which means you'll    have
  33.       to use _s_y_s_r_e_a_d() instead of normal stuff.
  34.  
  35.       _o_p_e_n_3() returns the process ID of the    child process.    It
  36.       doesn't return on failure: it    just raises an exception
  37.       matching /^open3:/.
  38.  
  39.      WWWWAAAARRRRNNNNIIIINNNNGGGG
  40.       It will not create these file    handles    for you.  You have to
  41.       do this yourself.  So    don't pass it empty variables
  42.       expecting them to get    filled in for you.
  43.  
  44.       Additionally,    this is    very dangerous as you may block
  45.       forever.  It assumes it's going to talk to something like
  46.       bbbbcccc, both writing to it and reading from it.  This is
  47.       presumably safe because you "know" that commands like    bbbbcccc
  48.       will read a line at a    time and output    a line at a time.
  49.       Programs like    ssssoooorrrrtttt that read their entire input stream
  50.       first, however, are quite apt    to cause deadlock.
  51.  
  52.       The big problem with this approach is    that if    you don't have
  53.       control over source code being run in    the child process, you
  54.       can't    control    what it    does with pipe buffering.  Thus    you
  55.       can't    just open a pipe to cat    -v and continually read    and
  56.       write    a line from it.
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.      Page 1                        (printed 10/23/98)
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.      IIIIPPPPCCCC::::::::OOOOppppeeeennnn3333((((3333))))   22223333////JJJJuuuullll////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))     IIIIPPPPCCCC::::::::OOOOppppeeeennnn3333((((3333))))
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.      Page 2                        (printed 10/23/98)
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.